home *** CD-ROM | disk | FTP | other *** search
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-
- <html>
- <head>
- <title>Lista dei contenuti della cartella</title>
- <style>
- span.output {
- font-family: Arial;
- font-size: 12px;
- color: #0000ff;
- }
- body {
- background-color: #ffff00;
- }
- </style>
- </head>
- <body>
- <?php
- $cartella=@opendir('immagini');
- // verifico per prima cosa se la cartella esiste. Il simbolo @ davanti alla funzione impedisce la visualizzazione dei messaggi d'errore a video
- if (!$cartella)
- {
- echo "Attenzione: la cartella non esiste";
- exit;
- }
- while (false !== ($file = readdir($cartella)))
- // il ciclo while verrα iterato finchΦ la cartella non sarα stata interamente letta. Ad ogni iterazione $file assume il nome del file successivo
- {
- // creo un array con i nomi dei file incontrati nella cartella
- $lista[]=$file;
- }
- $fine=count($lista)-2;
- if ($fine==0)
- {
- echo "Attenzione: Non ci sono immagini nella cartella";
- }
- else
- {
- echo "<h4>La cartella 'immagini' contiene questi file:</h4><p>";
- for ($i=2;$i<=count($lista)-1;$i++)
- {
- $ordine=$i-1;
- echo "----------------------------------<br>";
- echo "<span class='output'>File $ordine: $lista[$i]</span><br>";
- }
- }
- closedir($cartella);
- ?>
- </body>
- </html>
-